package xyz.yuzegod.megawalls.stats;

import xyz.yuzegod.megawalls.MegaWalls;
import xyz.yuzegod.megawalls.database.DataBase;
import xyz.yuzegod.megawalls.database.KeyValue;
import xyz.yuzegod.megawalls.effect.EffectManager;
import xyz.yuzegod.megawalls.effect.HologramEffect;
import xyz.yuzegod.megawalls.effect.KillMessage;
import xyz.yuzegod.megawalls.effect.TeamDisplayColor;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.game.team.TeamColor;

public class EffectStatsContainer
{
    private static DataBase database;
    private GamePlayer gamePlayer;
    private String hologramEffect;
    private String killMessage;
    private String redColor;
    private String greenColor;
    private String blueColor;
    private String yellowColor;
    private boolean enablePrefix;
    private boolean enableItalic;
    private boolean enableBold;
    private boolean surface;
    
    public EffectStatsContainer(final GamePlayer gamePlayer) {
        this.hologramEffect = "Default";
        this.killMessage = "Default";
        this.redColor = "RED";
        this.greenColor = "GREEN";
        this.blueColor = "BLUE";
        this.yellowColor = "YELLOW";
        this.enablePrefix = true;
        this.enableItalic = false;
        this.enableBold = false;
        this.surface = false;
        this.gamePlayer = gamePlayer;
    }
    
    public HologramEffect getHologramEffect() {
        return EffectManager.getHologramEffect(this.hologramEffect);
    }
    
    public KillMessage getKillMessage() {
        return EffectManager.getKillMessage(this.killMessage);
    }
    
    public TeamDisplayColor getColor(final TeamColor teamColor) {
        switch (teamColor) {
            case RED: {
                return this.getRedColor();
            }
            case GREEN: {
                return this.getGreenColor();
            }
            case BLUE: {
                return this.getBlueColor();
            }
            case YELLOW: {
                return this.getYellowColor();
            }
            default: {
                return TeamDisplayColor.RED;
            }
        }
    }
    
    public void setColor(final TeamColor teamColor, final TeamDisplayColor color) {
        switch (teamColor) {
            case RED: {
                this.updateRedColor(color.name());
                break;
            }
            case GREEN: {
                this.updateGreenColor(color.name());
                break;
            }
            case BLUE: {
                this.updateBlueColor(color.name());
                break;
            }
            case YELLOW: {
                this.updateYellowColor(color.name());
                break;
            }
        }
    }
    
    public TeamDisplayColor getRedColor() {
        return TeamDisplayColor.valueOf(this.redColor);
    }
    
    public TeamDisplayColor getGreenColor() {
        return TeamDisplayColor.valueOf(this.greenColor);
    }
    
    public TeamDisplayColor getBlueColor() {
        return TeamDisplayColor.valueOf(this.blueColor);
    }
    
    public TeamDisplayColor getYellowColor() {
        return TeamDisplayColor.valueOf(this.yellowColor);
    }
    
    public void updateHologramEffect(final String name) {
        this.hologramEffect = name;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("hologramEffect", name), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateKillMessage(final String name) {
        this.killMessage = name;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("killMessage", name), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateRedColor(final String name) {
        this.redColor = name;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("redColor", name), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateGreenColor(final String name) {
        this.greenColor = name;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("greenColor", name), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateBlueColor(final String name) {
        this.blueColor = name;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("blueColor", name), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateYellowColor(final String name) {
        this.yellowColor = name;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("yellowColor", name), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateEnablePrefix(final boolean enablePrefix) {
        this.enablePrefix = enablePrefix;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("enablePrefix", String.valueOf(enablePrefix)), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateEnableItalic(final boolean enableItalic) {
        this.enableItalic = enableItalic;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("enableItalic", String.valueOf(enableItalic)), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateEnableBold(final boolean enableBold) {
        this.enableBold = enableBold;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("enableBold", String.valueOf(enableBold)), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public void updateSurface(final boolean surface) {
        this.surface = surface;
        EffectStatsContainer.database.dbUpdate("megawalls_effects", new KeyValue("surface", String.valueOf(surface)), new KeyValue("uuid", this.gamePlayer.getUuid().toString()));
    }
    
    public GamePlayer getGamePlayer() {
        return this.gamePlayer;
    }
    
    public void setHologramEffect(final String hologramEffect) {
        this.hologramEffect = hologramEffect;
    }
    
    public void setKillMessage(final String killMessage) {
        this.killMessage = killMessage;
    }
    
    public void setRedColor(final String redColor) {
        this.redColor = redColor;
    }
    
    public void setGreenColor(final String greenColor) {
        this.greenColor = greenColor;
    }
    
    public void setBlueColor(final String blueColor) {
        this.blueColor = blueColor;
    }
    
    public void setYellowColor(final String yellowColor) {
        this.yellowColor = yellowColor;
    }
    
    public boolean isEnablePrefix() {
        return this.enablePrefix;
    }
    
    public void setEnablePrefix(final boolean enablePrefix) {
        this.enablePrefix = enablePrefix;
    }
    
    public boolean isEnableItalic() {
        return this.enableItalic;
    }
    
    public void setEnableItalic(final boolean enableItalic) {
        this.enableItalic = enableItalic;
    }
    
    public boolean isEnableBold() {
        return this.enableBold;
    }
    
    public void setEnableBold(final boolean enableBold) {
        this.enableBold = enableBold;
    }
    
    public boolean isSurface() {
        return this.surface;
    }
    
    public void setSurface(final boolean surface) {
        this.surface = surface;
    }
    
    static {
        EffectStatsContainer.database = MegaWalls.getInstance().getDataBase();
    }
}
